package com.kgc.bigdata.spark.scala

class SimpleObjectDemo {
}

class People {
  //定义属性
  var name: String = ""
  val age: Int = 10

  //定义方法
  def eat(): String = {
    name + " eat..."
  }

  def watchFootball(teamName: String) {
    println(name + " is watching match of " + teamName)
  }
}

object SimpleObjectDemo {
  def main(args: Array[String]) {
    val people = new People() //创建对象
    people.name = "Messi" //为name赋值
    println("name is : " + people.name)
    println("name is : " + people.name + " , age is " + people.age)

    //people.age = 27   //编译报错，因为age是val类型，值不能被修改

    //函数调用
    println("invoke eat method : " + people.eat)

    //编译报错：当调用的方法有入参时，一定需要带括号并传递入参
    //println("invoke watchFootball method : " + people.watchFootball())  //需要带入参
    println("invoke watchFootball method : " + people.watchFootball("Barcelona"))
  }
}

